package com.cqupt.scanning.system.consumer.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cqupt.scanning.system.admin.entity.PatientFoot;
import com.cqupt.scanning.system.consumer.service.ConsumerService;
import com.cqupt.scanning.system.utils.result.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Data: 2021/7/12 14:23
 * @Author: 宋宝梁
 */
@RestController
@RequestMapping("/consumer")
public class ConsumerController {

    private ConsumerService consumerService;

    @Autowired
    public ConsumerController(ConsumerService consumerService) {
        this.consumerService = consumerService;
    }

    /**
     * 获取当前设备的病人的数量
     * @return
     */
    @GetMapping("/statistics/getAllPatsCount")
    public R getAllPatsCount() {
        return consumerService.getAllPatsCount();
    }

    /**
     * 获取当前设备的病人信息
     * @param query
     * @param current
     * @param size
     * @return
     */
    @GetMapping("/statistics/getAllPats")
    public R getAllPats(@RequestParam("query") String query,
                        @RequestParam(value = "pageNum", defaultValue = "1") Integer current,
                        @RequestParam(value = "pageSize", defaultValue = "10") Integer size) {
        return consumerService.getAllPats(query,current, size);
    }

    /**
     * 筛选并获取当前设备的病人信息
     * @param current
     * @param size
     * @return
     */
    @GetMapping("/statistics/queryAllPats")
    public R queryAllPats(@RequestParam(value = "name",required = false) String name,
                          @RequestParam(value = "age_lower",required = false) String ageLower,
                          @RequestParam(value = "age_upper",required = false) String ageUpper,
                          @RequestParam(value = "doctor",required = false) String doctor,
                          @RequestParam(value = "height_lower",required = false) String heightLower,
                          @RequestParam(value = "height_upper",required = false) String heightUpper,
                          @RequestParam(value = "measureMode",required = false) String measureMode,
                          @RequestParam(value = "sex",required = false) String sex,
                          @RequestParam(value = "weight_lower",required = false) String weightLower,
                          @RequestParam(value = "weight_upper",required = false) String weightUpper,
                          @RequestParam(value = "phone",required = false) String phone,
                          @RequestParam(value = "beginTime",required = false) String beginTime,
                          @RequestParam(value = "endTime",required = false) String endTime,
                        @RequestParam(value = "pageNum", defaultValue = "1") Integer current,
                        @RequestParam(value = "pageSize", defaultValue = "10") Integer size) {
        return consumerService.queryAllPats(name,ageLower,ageUpper,doctor,heightLower,heightUpper,measureMode,sex, weightLower,weightUpper, phone,beginTime,endTime ,current, size);
    }
}

//    /**
//     * 根据时间段获取当前设备的病人信息
//     * @param beginTime
//     * @param endTime
//     * @param current
//     * @param size
//     * @return
//     */
//    @GetMapping("/statistics/queryAllByTime")
//    public R queryAllByTime(@RequestParam(value = "beginTime") String beginTime,
//                            @RequestParam(value = "endTime") String endTime,
//                        @RequestParam(value = "pageNum", defaultValue = "1") Integer current,
//                        @RequestParam(value = "pageSize", defaultValue = "10") Integer size) {
//        return consumerService.queryAllByTime(beginTime,endTime,current, size);
//    }


